import java.util.Scanner;

//reverse string in same flow - reversing each word

//												Please enter the input line
//												this is me
//
//												The input string is "this  is me"
//												The reversed string is "siht  si em "

public class Assignment9 {
	
	public static void main(String args[]) {
		Scanner s = new Scanner(System.in);
		System.out.println("Please enter the input line");
		String myinp = s.nextLine();
		System.out.format("The input string is \"%s\"", myinp);
		//find multiple words in the input line 
		String wordsarray[] = myinp.split(" ");
		String revwordsarray[] = new String[wordsarray.length];
		//reverse each word in the input 
		for(int k=0;k<wordsarray.length;k++) {
			//break the word into char[]
			char wordchararray[] = wordsarray[k].toCharArray();
			int mylength = wordchararray.length;
			char reverseword[] = new char[mylength];
			int j = 0;
			for(int i=mylength-1;i>=0;i--) {
				reverseword[j] = wordchararray[i]; 
				j++;
			}
			revwordsarray[k] = String.valueOf(reverseword);						
		}
		
		//print the reversed string
		System.out.format("%nThe reversed string is \""); 	
		for(int k=0;k<revwordsarray.length;k++) {
			if(k!=(revwordsarray.length-1))
				System.out.format("%s ", revwordsarray[k]); 	
			else
				System.out.format("%s", revwordsarray[k]); 	
		}		
		System.out.format("\"%n"); 
	}

}
